#include <cstdio>
#include <cmath>

int main( )
{
    int i, n, m;
    bool flag;
    __int64 a[ 100 ];
    __int64 s1, s2;
    while ( scanf("%d%d", &n, &m) != EOF )
    {
        s1 = s2 = 0;
        for ( i = 0; i < n; i++ )
        {
            scanf("%I64d", &a[ i ]);
            s2 += a[ i ];
        }
        s2 /= m;
        while ( 1 )
        {
            s1 = s2;
            s2 = 0;
            flag = false;
            for ( i = 0; i < n; i++ )
            {
                if ( a[ i ] > s1 )
                {
                    flag = true;
                    a[ i ] = s1;
                }
                s2 += a[ i ];
            }
            s2 /= m;
            if ( !flag )
                break;
        }
        printf("%I64d\n", s2);
    }
    return 0;
}
